/**
 * 
 */
package com.tomagency.cyberlab.client.ui.renderer;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.tomagency.cyberlab.client.events.KontaktEvent;
import com.tomagency.cyberlab.client.ui.ObjectListenView.CellRenderer;
import com.tomagency.cyberlab.client.ui.ObjectListenView.RenderType;
import com.tomagency.cyberlab.client.ui.ObjectListenView.RowRenderer;
import com.tomagency.cyberlab.client.ui.ObjectListenView.RowType;
import com.tomagency.cyberlab.client.ui.ObjectListenView.ObjectEventHandler;

import de.gammadata.gwt.proxy.KontaktListProxy;
import de.gammadata.gwt.proxy.PersistenceBeanListProxy;

/**
 * @author gfr
 *
 */
public class KontaktRowRendererImpl implements RowRenderer<KontaktEvent> {
	
	List<CellRenderer<KontaktEvent>> cellRendererList;
	
	public KontaktRowRendererImpl(){
		bind();
	}

	@Override
	public List<CellRenderer<KontaktEvent>> getCellRendererList(RenderType renderType) {
		
		return cellRendererList;
	}
	
	private void bind(){
		cellRendererList = new ArrayList<CellRenderer<KontaktEvent>>();
		cellRendererList.add(new KontaktNamenRenderer());
		cellRendererList.add(new KontaktAdressRenderer());
	}
	
	class KontaktNamenRenderer implements CellRenderer<KontaktEvent>{

		@Override
		public int getColSpan() {
			return 1;
		}

		@Override
		public Widget getColumnWidget(RowType rowType, ObjectEventHandler handler,
				Object dataObj) {
			KontaktListProxy kontakt = (KontaktListProxy)dataObj;
			Label name = new Label(kontakt.getNamenString());
			return name;
		}
		
	}
	
	class KontaktAdressRenderer implements CellRenderer<KontaktEvent>{

		@Override
		public int getColSpan() {
			return 1;
		}

		@Override
		public Widget getColumnWidget(RowType rowType, ObjectEventHandler handler,
				Object dataObj) {
			KontaktListProxy kontakt = (KontaktListProxy)dataObj;
			Label adr = new Label(kontakt.getAdressString());
			return adr;
		}
		
	}

}
